package com.chb.controller;

import com.chb.model.vo.Result;
import com.chb.service.FileService;
import com.chb.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author: 陈海彬
 * @date: Created in 2023/10/9 19:57
 * @description:
 * @modified By:
 * @version:
 */
@RequestMapping("/user")
@RestController
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private FileService fileService;


    /**
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 获取用户个人信息
     * @create time: 2023/10/9 19:59
     */
    @GetMapping("/getUserInfo")
    public Result getUserInfo() {
        return userInfoService.getUserInfo();
    }

    @PostMapping("/uploadPictures")
    public Result uploadPictures(@RequestParam("file") MultipartFile file) {
        // 上传图片到数据库
        String uploaded = fileService.upload(file);
        userInfoService.updateStaffUrl(uploaded);
        return Result.success();
    }
}